
#ifndef THREADCONTROLLER_H
#define THREADCONTROLLER_H

#include <QObject>
#include <QThread>
#include<QDebug>
#include "servermessageadapter.h"
#include "UIManager.h"
#include"loginwindow.h"
#include "Socket/TCPSocket.h"
#include"friendlist.h"
#include "Account/account.h"

#include"enrollwindow.h"
#include"chatwindow.h"
#include"findpassword.h"
#include<QMap>
#include<QList>
#include"groupchat.h"
#include"Task/login.h"
#include "reset.h"
#include"dialog.h"
#include<QTimer>
#include "sendcheck.h"
#include "infoform.h"

class ThreadController : public QObject
{
    Q_OBJECT
public:
    explicit ThreadController(QObject *parent = nullptr);
    void start();
signals:
  void startRunning(); // 用于触发新线程中的耗时操作函数
    void sig_phone_check(Package::ChecknumRequestSend);
    void sig_msg_requeset(QString);

public slots:
  void on_receivResult(); // 接收新线程中的结果
  void GetChatHistory(QString id,QList<QPair<QString,QString>> history);
  void GetFriendMsg(QString id ,QString msg);
  void  newfriend(QString id);
  void  newgroup(QString id);
  void getmyid(QString id);
  void GetGroupHistroy(QString id,QList<QPair<QString,QString>> history);
  void  GetGroupInfo(QString gid,QString uid,QString info);
private:
    class reset *myreset;
    ServerMessageAdapter* server_message_adapter;
    UIManager * ui_manager;
    QThread* ui_thread;
    QThread* back_thread;
   Loginwindow *login_window=nullptr;
   TCPSocket* tcp_socket;
friendlist *friend_list;
enrollwindow *enroll_window;
QMap <QString ,chatwindow*> main_chat;
QMap <QString ,groupchat*> group_chat;
sendcheck *mysendcheck ;

findpassword *myfindpassword;
int friendnum=0;
QString myid="";
QDialog *mydialog;

InfoForm *myinfo;


//    MainWindow w;

    void initBindTask();
//    int count =0;


};

#endif // THREADCONTROLLER_H
